
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllFodderTypes", query = "select myFodderType from FodderType myFodderType"),
		@NamedQuery(name = "findFodderTypeById", query = "select myFodderType from FodderType myFodderType where myFodderType.id = ?1"),
		@NamedQuery(name = "findFodderTypeByMemo", query = "select myFodderType from FodderType myFodderType where myFodderType.memo = ?1"),
		@NamedQuery(name = "findFodderTypeByMemoContaining", query = "select myFodderType from FodderType myFodderType where myFodderType.memo like ?1"),
		@NamedQuery(name = "findFodderTypeByName", query = "select myFodderType from FodderType myFodderType where myFodderType.name = ?1"),
		@NamedQuery(name = "findFodderTypeByNameContaining", query = "select myFodderType from FodderType myFodderType where myFodderType.name like ?1"),
		@NamedQuery(name = "findFodderTypeByPrimaryKey", query = "select myFodderType from FodderType myFodderType where myFodderType.id = ?1"),
		@NamedQuery(name = "findFodderTypeBySupply", query = "select myFodderType from FodderType myFodderType where myFodderType.supply = ?1"),
		@NamedQuery(name = "findFodderTypeBySupplyContaining", query = "select myFodderType from FodderType myFodderType where myFodderType.supply like ?1") })

@Table(catalog = "pig", name = "fodder_type")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "FodderType")
@XmlRootElement(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain")
public class FodderType implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "Id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "Name", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String name;
	/**
	* ������
	* 
	 */

	@Column(name = "Supply")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String supply;
	/**
	 */

	@Column(name = "Memo")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String memo;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "UnitId", referencedColumnName = "Id") })
	@XmlTransient
	Unit unit;
	/**
	 */
	@OneToMany(mappedBy = "fodderType", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.FeedTaskQuality> feedTaskQualities;
	/**
	 */
	@OneToMany(mappedBy = "fodderType", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.FodderStorage> fodderStorages;
	/**
	 */
	@OneToMany(mappedBy = "fodderType", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.FodderTake> fodderTakes;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	* ������
	* 
	 */
	public void setSupply(String supply) {
		this.supply = supply;
	}

	/**
	* ������
	* 
	 */
	public String getSupply() {
		return this.supply;
	}

	/**
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 */
	public String getMemo() {
		return this.memo;
	}

	/**
	 */
	public void setUnit(Unit unit) {
		this.unit = unit;
	}

	/**
	 */
	@JsonIgnore
	public Unit getUnit() {
		return unit;
	}

	/**
	 */
	public void setFeedTaskQualities(Set<FeedTaskQuality> feedTaskQualities) {
		this.feedTaskQualities = feedTaskQualities;
	}

	/**
	 */
	@JsonIgnore
	public Set<FeedTaskQuality> getFeedTaskQualities() {
		if (feedTaskQualities == null) {
			feedTaskQualities = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.FeedTaskQuality>();
		}
		return feedTaskQualities;
	}

	/**
	 */
	public void setFodderStorages(Set<FodderStorage> fodderStorages) {
		this.fodderStorages = fodderStorages;
	}

	/**
	 */
	@JsonIgnore
	public Set<FodderStorage> getFodderStorages() {
		if (fodderStorages == null) {
			fodderStorages = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.FodderStorage>();
		}
		return fodderStorages;
	}

	/**
	 */
	public void setFodderTakes(Set<FodderTake> fodderTakes) {
		this.fodderTakes = fodderTakes;
	}

	/**
	 */
	@JsonIgnore
	public Set<FodderTake> getFodderTakes() {
		if (fodderTakes == null) {
			fodderTakes = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.FodderTake>();
		}
		return fodderTakes;
	}

	/**
	 */
	public FodderType() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(FodderType that) {
		setId(that.getId());
		setName(that.getName());
		setSupply(that.getSupply());
		setMemo(that.getMemo());
		setUnit(that.getUnit());
		setFeedTaskQualities(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.FeedTaskQuality>(that.getFeedTaskQualities()));
		setFodderStorages(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.FodderStorage>(that.getFodderStorages()));
		setFodderTakes(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.FodderTake>(that.getFodderTakes()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("supply=[").append(supply).append("] ");
		buffer.append("memo=[").append(memo).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof FodderType))
			return false;
		FodderType equalCheck = (FodderType) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
